package com.thiswhyme.openfeign.client.feign.dto;

import lombok.AllArgsConstructor;

/**
 * Created by thiswhyme on 2020/8/16.
 */
@AllArgsConstructor
public enum UserType {

    STUDENT(0, "学生"),
    TEACHER(1, "老师");

    private Integer value;
    private String desc;

    public static UserType indexOf(int value) {
        for (UserType item : UserType.values()) {
            if (item.value == value) {
                return item;
            }
        }

        return null;
    }

    public static UserType nameOf(String name) {
        for (UserType item : UserType.values()) {
            if (item.toString().equals(name)) {
                return item;
            }
        }
        return null;
    }
}
